function createUserList() {
    return [
        {
            userId: 1,
            avatar: '111',
            username: 'admin',
            password: '111111',
            desc: '平台管理员',
            roles: [ '平台管理员' ],
            buttons: [ 'cuser.detail' ],
            routes: [ 'home' ],
            token: 'Admin Token'
        }
    ]
}

export default [
    {
        url: '/dev-api/users/login',
        method: 'POST',
        response: ( { body }: { body: { username: string, password: string } } ) => {
            const { username, password } = body
            const user = createUserList().find(item => item.username === username
                && item.password === password)
            if (!user) {
                return { code: 201, data: { message: '账户密码不正确' } }
            }
            return { code: 200, data: { token: user.token } }
        }
    },
    {
        // 获取用户信息
        url: '/dev-api/user/info',
        method: 'get',
        response: ( request: { headers: { token: string } } ) => {
            //获取请求头携带token
            const token = request.headers.token
            //查看用户信息是否包含有次token用户
            //没有返回失败的信息if(!checkUser)f//如果有返回成功信息
            const checkUser = createUserList()
                .find(( item ) => item.token === token)
            return { code: 200, data: { checkUser } }
        }
    }
]